/*
 * Copyright (C) Michael Opitz
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA
 */
#ifndef RS_SOCKET_H
#define RS_SOCKET_H

#define BAUDRATE B9600

#include <string>
#include <boost/shared_ptr.hpp>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>

#include "i_socket.h"
#include "socket/socket_exception.h"

using namespace std;

/** 
 * \brief This namespaces includes all nertwork related stuff.
 * \author Michael Opitz
 */
namespace network {
	/** 
	 * \brief This class represents a socket over the rs-232-interface.
	 */
	class rs_socket : public network::i_socket {
	public:
		/** 
		 * \brief rs_socket creates a new serial-socket over the
		 * appropriate device
		 * 
		 * \param file is the device, from which the socket should be
		 * created. (e.g. /dev/ttyS0)
		 */
		rs_socket(const string &file);
		virtual ~rs_socket();

		/** 
		 * \brief send sends a string over the socket.
		 * 
		 * \param str is the string which should be sended
		 */
		virtual void send(const string &str);
		/** 
		 * \brief recv receives a string over the socket.
		 * 
		 * \return a string is returned by the serial socket
		 */
		virtual string recv();
	private:
		int _fd;
	};
}

#endif
